<template>
	<view class="assets">
		<view class="top ufttop" v-if="type =='UFT'">
			<view class="left">
				<text style="font-size: 12px;">UFT静态</text>
				<text style="color:#03AD8F;">{{currdata.freeze | numFilter}}</text>
			</view>
			<view class="right">
				<text style="font-size: 12px;">UFT动态</text>
				<text style="color:#03AD8F;">{{currdata.balance | numFilter}}</text>
			</view>
		</view>
		<view class="top" v-if="type =='USDT'">
			<view class="left">
				<text style="font-size: 13px;">全部资产</text>
				<text style="color:#03AD8F;">{{currdata.balance*1+currdata.freeze*1 | numFilter}}</text>
			</view>
			<!-- <view class="right">
				<text style="font-size: 13px;">可用资产</text>
				<text style="color:#03AD8F;">{{currdata.balance | numFilter}}</text>
			</view> -->
		</view>
		<!-- <view class="money" v-if="type =='USDT'">
			<text class="iconfont">&#xe614;</text>
			冻结金额：<text style="color:#D14B64;">{{currdata.freeze}}</text>
		</view> -->
		<view class="buttom" v-if="type =='USDT'">
			<button style="background-color:#03AD8F;" class="smallBtn showtext" @click="golink('../WithdrawMoney/WithdrawMoney')">提币</button>
			<button style="background-color:#03AD8F;" class="smallBtn showtext" @click="golink('../recharge/recharge')">充币</button>
			<button class="smallBtn" style="margin-top: 30px;" @click="golink('../assets/assets?type=UFT')">挂售</button>
			<button class="smallBtn" style="margin-top: 30px;" @click="golink('../transfer/transfer')">转账</button>
		</view>
		<view class="buttom" v-if="type =='UFT'">
			<button style="background-color:#03AD8F;" class="smallBtn showtext" @click="golink('../exchange/stateexchange')">静态挂售</button>
			<button class="smallBtn" @click="golink('../exchange/dynamicexchange')">动态挂售</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: "",
				currdata: [], //币资产
				curr_id: '', //币种ID
			};
		},
		onLoad: function(option) {
			//获取路由传值
			this.type = option.type

			//动态修改title
			uni.setNavigationBarTitle({
				title: option.type
			});
			this.getData(this.type);
		},
		methods: {
			golink(link) {
				// 跳转到其他页面
				uni.navigateTo({
					url: link
				})
			},
			getData: function(type) {
				const _this = this;

				if (type === 'USDT') {
					_this.curr_id = 6
				} else if (type === 'UFT') {
					_this.curr_id = 7
				}
				//获取币种详情
				const data = {
					curr_id: _this.curr_id
				}
				this.$request.post("/api/index/getCurrDetail", {
						data: data
					})
					.then(res => {

						if (res.data.code == 1) {
							_this.currdata = res.data.data;


						}
					})
					.catch(error => {
						console.error('error:', error);
					});
			}
		},
		filters: {

			numFilter(value) {
				// 截取当前数据到小数点后两位
				let realVal = Number(value).toFixed(4)
				// num.toFixed(2)获取的是字符串
				return Number(realVal)
			}
		}

	}
</script>

<style lang="less">
	@import '../../common/iconfont.css';

	.assets {
		width: 100%;
		display: flex;
		flex-direction: column;

		.top {
			display: flex;
			height: 80px;
			border-top: 5px solid #F1F1F1;
			text-align: center;
			align-items: center;
			justify-content: space-around;
			padding: 0 20upx;
			font-size: 22px;

			.left {
				display: flex;
				flex-direction: column;
			}

			.right {
				display: flex;
				flex-direction: column;
			}
		}

		// .ufttop {
		// 	border-bottom: 10px solid #F1F1F1;
		// }

		.money {
			padding: 0 20px 10px;
			font-size: 14px;
			height: 20px;

			display: flex;
			align-items: center;

			.iconfont {
				color: #D14B64;
				display: flex;
				align-items: center;
				margin-right: 5px;
			}
		}

		.buttom {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: space-around;
			// margin-top: 30px;
			border-top: 10px solid #F1F1F1;
			padding-top: 20px;
			.showtext {
				box-shadow: 0 3px 10px rgb(3, 173, 143);
			}
		}
	}
</style>
